package com.usian.wemedia.controller.v1;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmNewsDto;
import com.usian.model.media.dtos.WmNewsPageReqDto;
import com.usian.model.media.pojos.WmNews;
import com.usian.wemedia.api.WmNewsControllerApi;
import com.usian.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wemedia/api/v1/news")
public class WmNewsController implements WmNewsControllerApi {

    @Autowired
    private WmNewsService wmNewsService;
    @PostMapping("/list")
    @Override
    public ResponseResult findPage(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.findPage(dto);
    }


    @PostMapping("/submit")
    @Override
    public ResponseResult submitNews(@RequestBody WmNewsDto dto,Integer status) {
        return wmNewsService.submit(dto,status);
    }

    @GetMapping("/one/{id}")
    @Override
    public ResponseResult findByIdNews(@PathVariable Integer id) {
        return wmNewsService.findByIdNews(id);
    }
    @PostMapping("/updateWmnews")
    @Override
    public ResponseResult updateStatusAndReason(WmNews wmNews) {
        return wmNewsService.updateStatusAndReason(wmNews);
    }
}
